using System.IO;

namespace SmartBoard.Book
{
    public  static partial class BookExtension
    {
        public static void Save(this Model.Book book, string filePath)
        {
            //TODO: Put a check to validate the path.
            var writer = new StreamWriter(filePath, false);
            writer.WriteLine("%IBF v1.0");
            writer.WriteLine(book.Name);
            if (book.Pages != null)
            {
                writer.WriteLine(book.Pages.Count);
                foreach (var page in book.Pages)
                {
                    writer.WriteLine(page.ActualSize);
                    writer.WriteLine(page.Number);
                    //page.Serialize(writer.BaseStream);
                    writer.WriteLine();
                }
            }
            else
                writer.WriteLine(0);
        }
    }
}